<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>qmanager.QManager</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="qmanager-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://django-qmanager.googlecode.com">QManager v0.2.1</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="qmanager-module.html">Module&nbsp;qmanager</a> ::
        Class&nbsp;QManager
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="qmanager.QManager-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class QManager</h1><span class="codelink"><a href="qmanager-pysrc.html#QManager">source&nbsp;code</a></span><br /><br />
<pre class="base-tree">
object --+
         |
        <strong class="uidshort">QManager</strong>
</pre>

<hr />
<p>Boilerplate Django manager which filters via a custom query.</p>
<div class="rst-section">
<h1 class="heading"><a id="rst-introduction" name="rst-introduction">Introduction</a></h1>
<p>The <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> class is a subclass of <tt class="rst-docutils literal"><span class="pre">django.db.models.Manager</span></tt>, which
defines several custom methods and attributes, and overrides several
others. For more information on usage, consult the module-level
documentation.</p>
</div>
<div class="rst-section">
<h1 class="heading"><a id="rst-overridden-methods" name="rst-overridden-methods">Overridden Methods</a></h1>
<blockquote>
<ul class="rst-simple">
<li><tt class="rst-docutils literal"><span class="pre">__init__</span></tt>
Initialize a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance, with an optional query.</li>
<li><tt class="rst-docutils literal"><span class="pre">__setattr__</span></tt>
Set an attribute on a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> to a certain value, with extras.</li>
<li><tt class="rst-docutils literal"><span class="pre">get_query_set</span></tt>
Return the query set for a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance's query.</li>
</ul>
</blockquote>
</div>
<div class="rst-section">
<h1 class="heading"><a id="rst-new-methods" name="rst-new-methods">New Methods</a></h1>
<blockquote>
<ul class="rst-simple">
<li><tt class="rst-docutils literal"><span class="pre">__invert__</span></tt>
Return the complementary query of this <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance.</li>
<li><tt class="rst-docutils literal"><span class="pre">__and__</span></tt>
Return the logical 'and' of a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</li>
<li><tt class="rst-docutils literal"><span class="pre">__or__</span></tt>
Return the logical 'or' of a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</li>
<li><tt class="rst-docutils literal"><span class="pre">__xor__</span></tt>
Return the logical 'xor' of a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</li>
<li><tt class="rst-docutils literal"><span class="pre">__rand__</span></tt>
Same as <tt class="rst-docutils literal"><span class="pre">__and__</span></tt>, but works in reverse.</li>
<li><tt class="rst-docutils literal"><span class="pre">__ror__</span></tt>
Same as <tt class="rst-docutils literal"><span class="pre">__or__</span></tt>, but works in reverse.</li>
<li><tt class="rst-docutils literal"><span class="pre">__rxor__</span></tt>
Same as <tt class="rst-docutils literal"><span class="pre">__xor__</span></tt>, but works in reverse.</li>
</ul>
</blockquote>
<p>Consult the respective documentation for a method for more information on
that method's usage and behaviour.</p>
</div>
<div class="rst-section">
<h1 class="heading"><a id="rst-the-query-attribute" name="rst-the-query-attribute">The <tt class="rst-docutils literal"><span class="pre">query</span></tt> Attribute</a></h1>
<p>A <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance has one additional attribute called <tt class="rst-docutils literal"><span class="pre">query</span></tt> which
holds a <tt class="rst-docutils literal"><span class="pre">Q</span></tt> instance - the representation of a database query in Django's
ORM. The <tt class="rst-docutils literal"><span class="pre">Q</span></tt> class is found in <tt class="rst-docutils literal"><span class="pre">django.db.models.query</span></tt>, and is itself
a subclass of <tt class="rst-docutils literal"><span class="pre">django.utils.tree.Node</span></tt>.</p>
<p>For more information on query objects, consult the official documentation
for Django's database API (this is included in the Django source).</p>
</div><br /><br />

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">query</span>=<span class="summary-sig-default">None</span>)</span><br />
      Initialize a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance, with an optional query.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__invert__" class="summary-sig-name">__invert__</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Return the complementary query of this <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__invert__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__and__" class="summary-sig-name">__and__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">query</span>)</span><br />
      Return the logical 'and' of this <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__and__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__or__" class="summary-sig-name">__or__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">query</span>)</span><br />
      Return the logical 'or' of this <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__or__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__xor__" class="summary-sig-name">__xor__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">query</span>)</span><br />
      Return the logical 'xor' of this <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__xor__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__setattr__" class="summary-sig-name">__setattr__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">attr</span>,
        <span class="summary-sig-arg">value</span>)</span><br />
      Set an attribute on a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> to a certain value, with extras.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__setattr__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#get_query_set" class="summary-sig-name">get_query_set</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Return the query set for this <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance's query.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.get_query_set">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__rand__" class="summary-sig-name">__rand__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">query</span>)</span><br />
      Return the logical 'and' of this <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__and__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__ror__" class="summary-sig-name">__ror__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">query</span>)</span><br />
      Return the logical 'or' of this <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__or__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="qmanager.QManager-class.html#__rxor__" class="summary-sig-name">__rxor__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">query</span>)</span><br />
      Return the logical 'xor' of this <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="qmanager-pysrc.html#QManager.__xor__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__str__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Properties</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Properties"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">query</span>=<span class="sig-default">None</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Initialize a <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> instance, with an optional query.</p>
<p>The <tt class="rst-docutils literal"><span class="pre">__init__</span></tt> method intializes a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance, giving it a
query by trying three things (in this order):</p>
<blockquote>
<ol class="rst-arabic simple">
<li>Arguments passed to <tt class="rst-docutils literal"><span class="pre">__init__</span></tt> are turned into <tt class="rst-docutils literal"><span class="pre">Q</span></tt>
instances by the <tt class="rst-docutils literal"><span class="pre">get_valid_query</span></tt> function in this module
(consult docstring for more information).</li>
<li>A <tt class="rst-docutils literal"><span class="pre">query</span></tt> attribute specified on the class itself. This may
be present due to subclassing (see docstring for the
<tt class="rst-docutils literal"><span class="pre">QManagerFactory()</span></tt> function in this module).</li>
<li>An empty <tt class="rst-docutils literal"><span class="pre">Q</span></tt> instance (given by initializing <tt class="rst-docutils literal"><span class="pre">Q</span></tt> with no
arguments).</li>
</ol>
</blockquote>
<p>It then calls the <tt class="rst-docutils literal"><span class="pre">Manager</span></tt> class's default <tt class="rst-docutils literal"><span class="pre">__init__</span></tt> method on
the instance.</p>
  <dl class="fields">
    <dt>Overrides:
      object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="__invert__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__invert__</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__invert__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Return the complementary query of this <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> instance.</p>
<p><tt class="rst-docutils literal"><span class="pre">__invert__</span></tt> provides a shortcut for finding the complement of a
query set by returning a new <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance in which <tt class="rst-docutils literal"><span class="pre">QNot</span></tt>
has been initialized on the query. Filtering by a <tt class="rst-docutils literal"><span class="pre">QNot</span></tt> instance (a
subclass of <tt class="rst-docutils literal"><span class="pre">Q</span></tt>) is the same as excluding by the original <tt class="rst-docutils literal"><span class="pre">Q</span></tt>, thus
allowing <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instances to be complemented.</p>
<p>By defining this as <tt class="rst-docutils literal"><span class="pre">__invert__</span></tt>, it allows the shortcut of
<tt class="rst-docutils literal"><span class="pre">~manager_name</span></tt> to be used instead of calling, for example,
<tt class="rst-docutils literal"><span class="pre">manager_name.not_()</span></tt>.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="__and__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__and__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">query</span>)</span>
    <br /><em class="fname">(And operator)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__and__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Return the logical 'and' of this <tt class="rst-rst-rst-docutils literal rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</p>
<p><tt class="rst-docutils literal"><span class="pre">__and__</span></tt> allows the combination of this instance's query with
another query via the 'and' logical operator. <tt class="rst-docutils literal"><span class="pre">Q</span></tt> objects support
this inherently, so all that needs to be done is for a new <tt class="rst-docutils literal"><span class="pre">QManager</span></tt>
instance to be created using the <tt class="rst-docutils literal"><span class="pre">&amp;</span></tt> of the instance's query and the
argument query.</p>
<p>In order to allow objects of all sorts to be and'd onto a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt>
instance, <tt class="rst-docutils literal"><span class="pre">get_valid_query</span></tt> is called on the argument. This does not
modify the original argument.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="__or__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__or__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">query</span>)</span>
    <br /><em class="fname">(Or operator)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__or__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Return the logical 'or' of this <tt class="rst-rst-rst-docutils literal rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</p>
<p><tt class="rst-docutils literal"><span class="pre">__or__</span></tt> allows the combination of this instance's query with
another query via the 'or' logical operator. <tt class="rst-docutils literal"><span class="pre">Q</span></tt> objects support this
inherently, so all that needs to be done is for a new <tt class="rst-docutils literal"><span class="pre">QManager</span></tt>
instance to be created using the <tt class="rst-docutils literal"><span class="pre">|</span></tt> of the instance's query and the
argument query.</p>
<p>In order to allow objects of all sorts to be or'd onto a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt>
instance, <tt class="rst-docutils literal"><span class="pre">get_valid_query</span></tt> is called on the argument. This does not
modify the original argument.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="__xor__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__xor__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">query</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__xor__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Return the logical 'xor' of this <tt class="rst-rst-rst-docutils literal rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</p>
<p><tt class="rst-docutils literal"><span class="pre">__xor__</span></tt> allows the combination of this instance's query with
another query via the 'xor' logical operator. <tt class="rst-docutils literal"><span class="pre">Q</span></tt> objects support
this inherently, so all that needs to be done is for a new <tt class="rst-docutils literal"><span class="pre">QManager</span></tt>
instance to be created using the <tt class="rst-docutils literal"><span class="pre">^</span></tt> of the instance's query and the
argument query.</p>
<div class="rst-section">
<h1 class="heading"><a id="rst-definition-and-implementation" name="rst-definition-and-implementation">Definition and Implementation</a></h1>
<p>The definition of an XOR is that it returns the records which fit
<em>either</em> one query or the other - but not <em>both</em>. In terms of set
theory (with A and B representing the sets returned by both queries),
the XOR of A and B is the intersection of the union of the complements
of A with B, and the union of A with B. In terms of boolean logic, XOR
is defined as the AND of the OR of NOT A with NOT B, and the OR of A
and B. In Python code:</p>
<pre class="rst-literal-block">
def xor(a, b):
    return ((not a) or (not b)) and (a or b)
</pre>
<p>Consult the source code for more information on the implementation.</p>
<p>In order to allow objects of all sorts to be xor'd onto a <tt class="rst-docutils literal"><span class="pre">QManager</span></tt>
instance, <tt class="rst-docutils literal"><span class="pre">get_valid_query</span></tt> is called on the argument. This does not
modify the original argument.</p>
</div>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="__setattr__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__setattr__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">attr</span>,
        <span class="sig-arg">value</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__setattr__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Set an attribute on a <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> to a certain value, with extras.</p>
<p>This does not differ greatly from the regular <tt class="rst-docutils literal"><span class="pre">__setattr__</span></tt>, except
that, if the <tt class="rst-docutils literal"><span class="pre">query</span></tt> attribute is being modified, then
<tt class="rst-docutils literal"><span class="pre">get_valid_query</span></tt> is called on the value which it is being set to, to
allow queries to be validated and to come from several different
sources.</p>
<p>As always, it is a good idea to consult the source code, as well as the
source and docstring for the <tt class="rst-docutils literal"><span class="pre">get_valid_query</span></tt> function.</p>
  <dl class="fields">
    <dt>Overrides:
      object.__setattr__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="get_query_set"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">get_query_set</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.get_query_set">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Return the query set for this <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> instance's query.</p>
<p>The <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> class's <tt class="rst-docutils literal"><span class="pre">get_query_set</span></tt> method is a simple line of
code:</p>
<pre class="rst-literal-block">
return super(QManager, self).get_query_set().filter(self.query)
</pre>
<p>What it essentially does is returns the basic <tt class="rst-docutils literal"><span class="pre">Manager</span></tt> class's query
set for a model (i.e. all of a model's records), filtered by the
<tt class="rst-docutils literal"><span class="pre">QManager</span></tt> instance's query. This forms the main part of the
abstraction which <tt class="rst-docutils literal"><span class="pre">QManager</span></tt> provides.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="__rand__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__rand__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">query</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__and__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Return the logical 'and' of this <tt class="rst-rst-rst-rst-docutils literal rst-rst-rst-docutils literal rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</p>
<p><tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">__and__</span></tt> allows the combination of this instance's query with
another query via the 'and' logical operator. <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">Q</span></tt> objects support
this inherently, so all that needs to be done is for a new <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt>
instance to be created using the <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">&amp;</span></tt> of the instance's query and the
argument query.</p>
<p>In order to allow objects of all sorts to be and'd onto a <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt>
instance, <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">get_valid_query</span></tt> is called on the argument. This does not
modify the original argument.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="__ror__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__ror__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">query</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__or__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Return the logical 'or' of this <tt class="rst-rst-rst-rst-docutils literal rst-rst-rst-docutils literal rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</p>
<p><tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">__or__</span></tt> allows the combination of this instance's query with
another query via the 'or' logical operator. <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">Q</span></tt> objects support this
inherently, so all that needs to be done is for a new <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt>
instance to be created using the <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">|</span></tt> of the instance's query and the
argument query.</p>
<p>In order to allow objects of all sorts to be or'd onto a <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt>
instance, <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">get_valid_query</span></tt> is called on the argument. This does not
modify the original argument.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="__rxor__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__rxor__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">query</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="qmanager-pysrc.html#QManager.__xor__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Return the logical 'xor' of this <tt class="rst-rst-rst-rst-docutils literal rst-rst-rst-docutils literal rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt> with another query.</p>
<p><tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">__xor__</span></tt> allows the combination of this instance's query with
another query via the 'xor' logical operator. <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">Q</span></tt> objects support
this inherently, so all that needs to be done is for a new <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt>
instance to be created using the <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">^</span></tt> of the instance's query and the
argument query.</p>
<div class="rst-section">
<h1 class="rst-heading heading"><a id="rst-definition-and-implementation" name="rst-definition-and-implementation">Definition and Implementation</a></h1>
<p>The definition of an XOR is that it returns the records which fit
<em>either</em> one query or the other - but not <em>both</em>. In terms of set
theory (with A and B representing the sets returned by both queries),
the XOR of A and B is the intersection of the union of the complements
of A with B, and the union of A with B. In terms of boolean logic, XOR
is defined as the AND of the OR of NOT A with NOT B, and the OR of A
and B. In Python code:</p>
<pre class="rst-rst-literal-block rst-literal-block">
def xor(a, b):
    return ((not a) or (not b)) and (a or b)
</pre>
<p>Consult the source code for more information on the implementation.</p>
<p>In order to allow objects of all sorts to be xor'd onto a <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">QManager</span></tt>
instance, <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">get_valid_query</span></tt> is called on the argument. This does not
modify the original argument.</p>
</div>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="qmanager-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://django-qmanager.googlecode.com">QManager v0.2.1</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0beta1 on Thu Jul 24 09:34:06 2008
    </td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
